// 导入类型声明文件
import type { CartItem } from '@/types/cart'
// 导入请求接口响应器&拦截器
import { http } from '@/utils/http'

// 加入购物车
export const addCartAPI = (data : { skuId : string, count : number }) => {
  return http({
    url: "/member/cart",
    method: "POST",
    data
  })
}

// 获取购物车API
export const getCartAPI = () => {
  return http<CartItem[]>({
    url: "/member/cart",
    method: "GET"
  })
}

// 删除购物车API
export const delCartAPI = (data : { ids : String[] }) => {
  return http({
    url: "/member/cart",
    method: "DELETE",
    data
  })
}


// 修改购物车商品数量API
export const changeCartNumberAPI = (skuId : string, data : { selected ?: boolean, count ?: number }) => {
  return http({
    url: `/member/cart/${skuId}`,
    method: "PUT",
    data
  })
}


// 修改购物车商品选中状态API
export const changeCartSelectAPI = (data : { selected : boolean }) => {
  return http({
    url:"/member/cart/selected",
    method:"PUT",
    data
  })
}
